package com.qf.hospital.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.hospital.entity.Pharmacy;
import com.qf.hospital.mapper.PharmacyMapper;
import com.qf.hospital.service.PharmacyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Administrator
 * @version V1.0
 * @Project hospital
 * @Package com.qf.hospital.service.impl
 * @Description: ${TODO}
 * @Date 2021/10/21 14:19
 */

@Service
public class PharmacyServiceImpl implements PharmacyService {

    @Autowired
    private PharmacyMapper pharmacyMapper;

    @Override
    public PageInfo<Pharmacy> findPharmacyInfo(String drugname, Integer page, Integer limit) {
        PageHelper.startPage(page, limit);
        List<Pharmacy> list = pharmacyMapper.findPharmacyInfos(drugname);
        PageInfo<Pharmacy> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public int findCountByName(Integer reportId,String durgname) {

        return pharmacyMapper.findCountByNameAndId(reportId,durgname);
    }

    @Override
    public void jianNum(Integer durgnum) {
        pharmacyMapper.updateDrunNum(durgnum);
    }

    @Override
    public Double findPrice(String durgname) {
       return pharmacyMapper.findPriceByName(durgname);
    }

}
